                                                                     
                                                                     
                                                                     
                                             
import java.io.File;

import org.eclipse.swt.SWT;

import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Image;

import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

public class FrontEnd extends Thread implements Runnable{
  Display display = new Display();
  Shell shell = new Shell(display,SWT.TITLE | SWT.MIN | SWT.CLOSE);
  Label label;  
  Label heading;
  Label chooseExp;
  Button buttonSelectDir;
  Button buttonSelectFile;
  Button buttonSingleClass;
  Button buttonMultiClass;
  Button buttonClassIns;
  Button buttonIconSave;
  Button buttonStartExp;
  Button buttonClient;
  Button buttonURI;
  Button buttonPCE;
  
  //Button button 
  Button buttonConexp;
  Button buttonGalicia;
  
  
  boolean dirChosen;
  boolean singleClassChosen;
  boolean multiClassChosen;
  boolean classInsChosen;
  boolean clientChosen;
  boolean URIChosen;
  boolean PCEChosen;
  boolean multi;
  
  boolean conChosen;
  boolean galChosen;
  
  String[] selectedDirFiles; 
  String[] selectedFiles;
  String[] fileNames;
  String outputFileName;
  Text textIconFile;
  
  int max_files=1000;
  int num_files;
  int index;
  String selectedDir;
  String fileFilterPath = "C:\\";

  public void dirlist(String dname){
	   
	    File dir = new File(dname);
	    String[] chld = dir.list();
	    if(chld == null){
	      System.out.println("Specified directory does not exist or is not a directory.");
	      System.exit(0);
	    }else{
	    	
	    	 for(int i = 0; i < chld.length; i++){
	         
	    		 String fileName = chld[i];
	    	   
	    	 if(fileName.endsWith(".java"))
	        {
	    		 num_files++;
		         selectedDirFiles[i]=dname+"\\"+fileName;
		         fileNames[i]=fileName;
	  
	        }
	      }
	    }
	  
	    
	    fileFilterPath=dname+"\\";
	
  }
   public FrontEnd() {
    dirChosen=false;
    singleClassChosen=false;
    multiClassChosen=false;
    classInsChosen=false;
    clientChosen=false;
    URIChosen=false;
    PCEChosen=false;
    conChosen=false;
    galChosen=false;
    
    multi=false;
    num_files=0;   
	index=0;
	
	shell.setText("FCA Parser");
    shell.addListener(SWT.Close, new Listener() {
	      public void handleEvent(Event event) {
	        
	        MessageBox messageBox = new MessageBox(shell, SWT.ICON_QUESTION
	                  | SWT.YES | SWT.NO);  
	    	messageBox.setText("Exiting FCA Parser");
	        messageBox.setMessage("Do you really want to exit?");
	        event.doit = messageBox.open() == SWT.YES;
	      }
	    });

	
	
	selectedDirFiles=new String[max_files];
    fileNames=new String[max_files];
	label = new Label(shell, SWT.APPLICATION_MODAL | SWT.WRAP);
    label.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
    
    label.setText("1. Select a dir/file containing java class(s).\n"+
    "2. Select one of the techniques to be applied.\n"+
    "3. Select a Concept Explorer.\n"+
    "4. Save output file and generate Lattice ");
    
    
    buttonSelectDir = new Button(shell, SWT.PUSH);
    buttonSelectDir.setText("Select a Java Package");
    buttonSelectDir.setToolTipText("Select a complete Java Package");
    buttonSelectDir.addListener(SWT.Selection, new Listener(){
     
    	public void handleEvent(Event event) {
    		DirectoryDialog directoryDialog = new DirectoryDialog(shell);
    		dirChosen=true;
    		
   		
    		directoryDialog.setFilterPath(selectedDir);
    		directoryDialog.setMessage("Please select a directory and click OK");
    		String dir = directoryDialog.open();
    		if(dir != null) {
    			label.setText("Selected dir: " + dir);
    			selectedDir = dir;
    			dirlist(dir);
    		}
        
    	}
    });
    
    buttonSelectFile = new Button(shell, SWT.PUSH);   
    buttonSelectFile.setText("Select a Class/Multiple Classes");
    buttonSelectFile.setToolTipText("Select single or multiple java classes");
    buttonSelectFile.addListener(SWT.Selection, new Listener() {
      
    	public void handleEvent(Event event) {
    		multi=true;
    		 
    		FileDialog fileDialog = new FileDialog(shell, SWT.MULTI);
    		fileDialog.setFilterPath(fileFilterPath);        
    		fileDialog.setFilterExtensions(new String[]{"*.java"});
    		fileDialog.setFilterNames(new String[]{ "JAVA FILE(S)"});
        
    		String firstFile = fileDialog.open();

    		if(firstFile != null) {
    
    			fileFilterPath = fileDialog.getFilterPath();
        
    			selectedFiles = fileDialog.getFileNames();         
    		
    			
    			StringBuffer sb = new StringBuffer("Selected files under dir " + fileDialog.getFilterPath() +  ": \n");
    			for(int i=0; i<selectedFiles.length; i++) {
            
    				num_files++;
    				selectedDirFiles[index]= fileFilterPath+"\\"+selectedFiles[i];
    				
    			
    				fileNames[index]=selectedFiles[i];
    				index++;
    				
    				sb.append(selectedFiles[i] + "\n");
          }
    				label.setText(sb.toString());
                    
    				
    				
    		}
      }
    });
   
    //Heading for Radio Button
    GridData gridData0 = new GridData(GridData.FILL_HORIZONTAL);
    gridData0 = new GridData();
    gridData0.horizontalSpan = 60;
    gridData0.horizontalAlignment = GridData.BEGINNING;
    
    heading = new Label(shell, SWT.None);   
    heading.setLayoutData(gridData0);
    heading.setText("Select a Technique :");
    
    //Heading for Choose Explorer
    GridData gridData9 = new GridData(GridData.FILL_HORIZONTAL);
    gridData9 = new GridData();
    gridData9.horizontalSpan = 60;
    gridData9.horizontalAlignment = GridData.BEGINNING;
    
    chooseExp= new Label(shell, SWT.None);   
    chooseExp.setLayoutData(gridData9);
    chooseExp.setText("Select an Explorer:");
    
    	
    
   
    //Single Class
    GridData gridData1 = new GridData(GridData.FILL_HORIZONTAL);
    gridData1 = new GridData();
    gridData1.horizontalSpan = 60;
    gridData1.horizontalAlignment = GridData.BEGINNING;
    
    buttonSingleClass = new Button(shell, SWT.RADIO);   
    buttonSingleClass.setLayoutData(gridData1);
    buttonSingleClass.setText("Method-Attribute");
    buttonSingleClass.setToolTipText("Examines the Relationship between Methods and Attributes of a Single Java Class");
    buttonSingleClass.addSelectionListener(new SelectionAdapter() {
    	public void widgetSelected(SelectionEvent e) {
    	
    	    singleClassChosen=true;
    	    multiClassChosen=false;
    	    classInsChosen=false;
    	    clientChosen=false;
    	    URIChosen=false;
		    PCEChosen=false;
    	}
    	
    });
   
   
    //URI
    GridData gridDataURI = new GridData(GridData.FILL_HORIZONTAL);
    gridDataURI = new GridData();
    gridDataURI.horizontalSpan = 60;
    gridDataURI.horizontalAlignment = GridData.BEGINNING;
    
    buttonURI = new Button(shell, SWT.RADIO);   
    buttonURI.setLayoutData(gridDataURI);
    buttonURI.setText("URI/Gabin");
    buttonURI.setToolTipText("Examines the Relationship between Methods, Attributes and Classes Referenced in a Single Java Class");
    buttonURI.addSelectionListener(new SelectionAdapter() {
    	public void widgetSelected(SelectionEvent e) {
    	
    	    URIChosen=true;
    		singleClassChosen=false;
    	    multiClassChosen=false;
    	    classInsChosen=false;
    	    clientChosen=false;
    	    PCEChosen=false;
		
    	}
    	
    });
    
    //PCE
    GridData gridDataPCE = new GridData(GridData.FILL_HORIZONTAL);
    gridDataPCE = new GridData();
    gridDataPCE.horizontalSpan = 60;
    gridDataPCE.horizontalAlignment = GridData.BEGINNING;
    
    buttonPCE = new Button(shell, SWT.RADIO);   
    buttonPCE.setLayoutData(gridDataURI);
    buttonPCE.setText("Principle Class Views");
    buttonPCE.setToolTipText("Extracts principal class and genererates views");
    buttonPCE.addSelectionListener(new SelectionAdapter() {
    	public void widgetSelected(SelectionEvent e) {
    	
    	    PCEChosen=true;
    		URIChosen=false;
    		singleClassChosen=false;
    	    multiClassChosen=false;
    	    classInsChosen=false;
    	    clientChosen=false;
    	    
		
    	}
    	
    });
     
  //Multiple Classes
    
    GridData gridData2 = new GridData(GridData.FILL_HORIZONTAL);
    gridData2 = new GridData();
    gridData2.horizontalSpan = 40;
    gridData2.horizontalAlignment = GridData.CENTER;
    buttonMultiClass = new Button(shell, SWT.RADIO);   
    buttonMultiClass.setLayoutData(gridData2);
    buttonMultiClass.setText("Common Properties");
    buttonMultiClass.setToolTipText("Detects Class Hierachies by examining common Attributes and Methods across Java Classes");
    buttonMultiClass.addSelectionListener(new SelectionAdapter() {
    	public void widgetSelected(SelectionEvent e) {
    		
    	 multiClassChosen=true;
    	 singleClassChosen=false;
    	 classInsChosen=false;
    	 clientChosen=false;
    	 URIChosen=false;
    	 PCEChosen=false;
    	}
    
    
    });
   
   //Class Instantiation
    
    GridData gridData3 = new GridData(GridData.FILL_HORIZONTAL);
    gridData3 = new GridData();
    gridData3.horizontalSpan = 40;
    gridData3.horizontalAlignment = GridData.END;
    
      
    buttonClassIns = new Button(shell, SWT.RADIO);   
    buttonClassIns.setLayoutData(gridData3);
    buttonClassIns.setText("Class Coupling");
    buttonClassIns.setToolTipText("Examines Methods Invoced and Atrributes Acessed across Java Classes");
    buttonClassIns.addSelectionListener(new SelectionAdapter() { 
    	public void widgetSelected(SelectionEvent e) {  
    	
    		singleClassChosen=false; 
    		multiClassChosen=false;
    		classInsChosen=true;
    	    clientChosen=false;
    	    URIChosen=false;
    	    PCEChosen=false;
    	}
    });
   
    //Client Code
    
    GridData gridData4 = new GridData(GridData.FILL_HORIZONTAL);
    gridData4 = new GridData();
    gridData4.horizontalSpan = 40;
    gridData4.horizontalAlignment = GridData.END;
    
      
    buttonClient = new Button(shell, SWT.RADIO);   
    buttonClient.setLayoutData(gridData4);
    buttonClient.setText("Client Code");
    buttonClient.setToolTipText("Suggests Refactoring by examining Client Code");
    buttonClient.addSelectionListener(new SelectionAdapter() { 
    	public void widgetSelected(SelectionEvent e) {  
    	
    		singleClassChosen=false; 
    		multiClassChosen=false;
    		classInsChosen=false;
    	    clientChosen=true;
    	    URIChosen=false;
    	    
    	}
    });
   
    
    //Button conExp
    
    
    GridData gridData10 = new GridData(GridData.FILL_HORIZONTAL);
    gridData10 = new GridData();
    gridData10.horizontalSpan = 40;
    gridData10.horizontalAlignment = GridData.END;
    
      
    buttonConexp = new Button(shell, SWT.RADIO);   
    buttonConexp.setLayoutData(gridData10);
    buttonConexp.setText("ConExp");
    buttonConexp.setToolTipText("A Concept Explorer");
    buttonConexp.addSelectionListener(new SelectionAdapter() { 
    	public void widgetSelected(SelectionEvent e) {  
    	
    		conChosen=true;
    		galChosen=false;
    	}
    });
    

    //Button Galicia
    
    GridData gridData11 = new GridData(GridData.FILL_HORIZONTAL);
    gridData11 = new GridData();
    gridData11.horizontalSpan = 40;
    gridData11.horizontalAlignment = GridData.END;
    
      
    buttonGalicia = new Button(shell, SWT.RADIO);   
    buttonGalicia.setLayoutData(gridData11);
    buttonGalicia.setText("Galicia");
    buttonGalicia.setToolTipText("A Concept Explorer");
    buttonGalicia.addSelectionListener(new SelectionAdapter() { 
    	public void widgetSelected(SelectionEvent e) {  
    	
    		galChosen=true;
    		conChosen=false;
    	}
    });
    
    
    
    //Start Explorer
    
    GridData gridData5 = new GridData(GridData.FILL_HORIZONTAL);
    gridData5 = new GridData();
    gridData5.horizontalSpan = 40;
    gridData5.horizontalAlignment = GridData.END;
    buttonStartExp = new Button(shell, SWT.PUSH);   
    buttonStartExp.setLayoutData(gridData5);
    buttonStartExp.setText("Start Concept Explorer");
    buttonStartExp.setToolTipText("Launch Concept Explorer to generate Lattice");

    buttonStartExp.addSelectionListener(new SelectionAdapter() {
    	public void widgetSelected(SelectionEvent e) {


    		if(galChosen==true){


    			new lattice.Start();
    		
    		}
    		
    		else if(conChosen==true){
    		  new conexp.frontend.ConceptExplorer();
    		}
    	 
    		else if(conChosen==false && galChosen==false){
    			
    		
    			 MessageBox messageBox = new MessageBox(shell, SWT.ICON_ERROR
    	    	          |SWT.OK);  
    	    	    	messageBox.setText("Message");
    	    	        messageBox.setMessage("You have not selected any Concept Explorer");
    	    	        e.doit = messageBox.open() == SWT.OK;
    		
    		
    		
    		
    		
    		
    		}
    	
    	
    	
    	}
    
    
    });
    //Make dir
    try{
	    String strDirectoy ="InfoFiles";
	    // Create one directory
	    boolean success = (new File(strDirectoy)).mkdir();
	    if (success) {
	      System.out.println("Directory: " + strDirectoy + " created");
	    }    
	   }catch (Exception e1){//Catch exception if any
	      System.err.println("Error: " + e1.getMessage());
   }
   //Save Output 
    	GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    	gridData = new GridData();
    	gridData.horizontalSpan = 40;
    	gridData.horizontalAlignment = GridData.BEGINNING;
    	buttonIconSave = new Button(shell, SWT.SAVE);
    	buttonIconSave.setLayoutData(gridData);
    	buttonIconSave.setText("Save Output File As");
    	buttonIconSave.setToolTipText("Generate and Save File");
    	
    	buttonIconSave.addSelectionListener(new SelectionAdapter() {
    	public void widgetSelected(SelectionEvent e) {
    		
    		if(num_files==0){
    			  MessageBox messageBox = new MessageBox(shell, SWT.ICON_ERROR
    	          |SWT.OK);  
    	    	messageBox.setText("Message");
    	        messageBox.setMessage("You have not selected any file for parsing");
    	        e.doit = messageBox.open() == SWT.OK;
    		}
    		
    		
    		else if(singleClassChosen==false && multiClassChosen==false &&classInsChosen==false &&clientChosen==false && URIChosen==false && PCEChosen==false){
    			
    	    	
  			  MessageBox messageBox = new MessageBox(shell, SWT.ICON_ERROR
  	    	          |SWT.OK);  
  	    	    	messageBox.setText("Message");
  	    	        messageBox.setMessage("You have not selected any Technique");
  	    	        e.doit = messageBox.open() == SWT.OK;
  		
  		}
  		
  		
    		
    		
    		
    		
    		
    		
    		else if(conChosen==false && galChosen==false){
    			
    	
    			  MessageBox messageBox = new MessageBox(shell, SWT.ICON_ERROR
    	    	          |SWT.OK);  
    	    	    	messageBox.setText("Message");
    	    	        messageBox.setMessage("You have not selected the Explorer");
    	    	        e.doit = messageBox.open() == SWT.OK;
    		
    		}
    		
    		
    		
    		
    		
    		
    		else{
    		
    		
    			
    			
    		FileDialog dialog = new FileDialog(shell, SWT.SAVE);
    		dialog.setFilterPath("c:\\"); 
    		
    		if(singleClassChosen==true){
    			
    			if(conChosen==true){
    			
    				dialog.setFileName("Method-Attribute.csv");          
    			}
    			else if(galChosen==true){
    				dialog.setFileName("Method-Attribute.rcf");
    			
    			}
    		
    		
    		}

    		if(multiClassChosen==true){
    			
    			if(conChosen==true){
    				dialog.setFileName("CommonProperties.csv");          
    			}
    			else if(galChosen==true){
    				dialog.setFileName("CommonPropertiesClasses.rcf");
    			}
    		}

    		if(classInsChosen==true){
    			
    			if(conChosen==true){
    				dialog.setFileName("ClassCoupling.csv");          
    			}
    			else if(galChosen==true){
    				dialog.setFileName("ClassCoupling.rcf");
    			}
    		}

    		if(clientChosen==true){
    			if(conChosen==true){
    			
    				dialog.setFileName("ClientCode.csv");          
    			}
    			else if(galChosen==true){
    				dialog.setFileName("ClientCode.rcf");
    			}
    		
    		
    		}
    		
    		if(URIChosen==true){
    			if(conChosen==true){
    			
    				dialog.setFileName("URI.csv");          
    			}
    			else if(galChosen==true){
    				dialog.setFileName("URI.rcf");
    			}
    		
    		
    		}
    		if(PCEChosen==true){
    			if(PCEChosen==true){
    			
    				dialog.setFileName("PCE.csv");          
    			}
    			else if(galChosen==true){
    				dialog.setFileName("PCE.rcf");
    			}
    		
    		
    		}
    	
    		
    		
    		 if(conChosen==true){
    		
    			dialog.setFilterExtensions(new String[] { "*.csv" }); 
    		}
    		
    		
    		else if(galChosen==true){
    			dialog.setFilterExtensions(new String[] { "*.rcf" });
    		}
    		
    	
    		
    		String path = dialog.open();
         
    		if (path != null) {        	
            //textIconFile.setText(path);
    			outputFileName=path;       
            
    		}
          
    		if(singleClassChosen==true){
    			SingleClassContext newConexp=new SingleClassContext(); 
    			
    			if(conChosen==true){
    			
    				newConexp.generateConexpInput(selectedDirFiles[0], outputFileName);
    		
    			}
    			
    			else if(galChosen==true){
    				
    				newConexp.generateGaliciaInput(selectedDirFiles[0], outputFileName);
    			
    			}
    			num_files=0;
    		    index=0;
    		    singleClassChosen=false;
    		    multiClassChosen=false;
      		    classInsChosen=false;
      		    clientChosen=false;
    		    URIChosen=false;
    		    PCEChosen=false;
    		}
    		
    		else if(URIChosen==true){
    			URIContext newConexp=new URIContext(); 
    			
    			if(conChosen==true){
    			
    				newConexp.generateConexpInput(selectedDirFiles[0], outputFileName);
    		
    			}
    			
    			else if(galChosen==true){
    				
    				newConexp.generateGaliciaInput(selectedDirFiles[0], outputFileName);
    			
    			}
    			num_files=0;
    		    index=0;
    		    singleClassChosen=false;
    		    multiClassChosen=false;
      		    classInsChosen=false;
      		    clientChosen=false;
    		    URIChosen=false;
    		    PCEChosen=false;
    		}
    		
    		else if(PCEChosen==true){
     
    			PCEContext newPCE=new PCEContext();
    			
    			if(conChosen==true){
    			
    				newPCE.generateConexpInput(selectedDirFiles,num_files,outputFileName);
    			
    			
    			
    			}
    			
    			else if(galChosen==true){
    				
    			   newPCE.generateGaliciaInput(selectedDirFiles,num_files,outputFileName);
    			
    			}
    			num_files=0;
    		    index=0;
    		    singleClassChosen=false;
    		    multiClassChosen=false;
      		    classInsChosen=false;
      		    clientChosen=false;
    		    URIChosen=false;
    		    PCEChosen=false;
    		}
    		
    		
    		else if(multiClassChosen==true){
    				CommonPropertiesContext newConexp=new CommonPropertiesContext();      
    			
    				if(conChosen==true){
    				  
    					System.out.println(num_files);
    					newConexp.generateConExpInput(fileNames,selectedDirFiles, outputFileName,num_files);
    				}
    			
    				else if(galChosen==true){
    					newConexp.generateGaliciaInput(fileNames,selectedDirFiles, outputFileName,num_files);
    			
    				}
    			
    				num_files=0;	
    				index=0;
    				 singleClassChosen=false;
    	    		 multiClassChosen=false;
    	      		 classInsChosen=false;
    	      		 clientChosen=false;
    	      	     URIChosen=false;
    	      	     PCEChosen=false;
    		}
            
    		else if(classInsChosen==true){
    		    
    			ClassCouplingContext newConexp= new ClassCouplingContext();
    			
    			if(conChosen==true){
    				
    			
    				System.out.println(num_files);
    				newConexp.generateConExpInput(selectedDirFiles, outputFileName, num_files);
    			}
    			
    			else if(galChosen==true){
    				
    				newConexp.generateGaliciaInput(selectedDirFiles, outputFileName, num_files);
    			
    			}
    			
    			
    			num_files=0;
    			index=0;
    			singleClassChosen=false;
     		    multiClassChosen=false;
       		    classInsChosen=false;
       		    clientChosen=false;
       		    URIChosen=false;
    		    PCEChosen=false;
    		}
    	
    		else if(clientChosen==true){
    		    
    			ClientContext newConexp= new ClientContext();
    			
    			if(conChosen==true){
    				
    		
    				newConexp.generateConExpInput(selectedDirFiles, outputFileName, num_files);
    			}
    			
    			else if(galChosen==true){
    				
    				newConexp.generateGaliciaInput(selectedDirFiles, outputFileName, num_files);
    			
    			
    			
    			}
    			num_files=0;
    			index=0;
    			singleClassChosen=false;
     		    multiClassChosen=false;
       		    classInsChosen=false;
       		    clientChosen=false;
       		    URIChosen=false;
    		    PCEChosen=false;
    		}
    	
    		
    	}
       
    	}
    
    });
   
    	  //create the menu system
        Menu m = new Menu(shell, SWT.BAR);
       
     // create a file menu and add an exit item
        final MenuItem file = new MenuItem(m, SWT.CASCADE);
        file.setText("File");
        final Menu filemenu = new Menu(shell, SWT.DROP_DOWN);
        file.setMenu(filemenu);
     
        // create an exit menu item
        final MenuItem exitItem = new MenuItem(filemenu, SWT.PUSH);
        exitItem.setText("Exit");
       
      
        exitItem.addSelectionListener(new SelectionAdapter(){;
        
       
          public void widgetSelected(SelectionEvent e) {
            MessageBox messageBox = new MessageBox(shell, SWT.ICON_QUESTION
                | SWT.YES | SWT.NO);
            messageBox.setMessage("Do you really want to exit?");
            messageBox.setText("Exiting FCA Parser");
            int response = messageBox.open();
            if (response == SWT.YES)
              System.exit(0);
          }
        });
        
        
        
        
        
        final MenuItem help = new MenuItem(m, SWT.CASCADE);
        help.setText("Help");
        final Menu helpmenu = new Menu(shell, SWT.DROP_DOWN);
        help.setMenu(helpmenu);
        final MenuItem aboutItem = new MenuItem(helpmenu, SWT.PUSH);
        aboutItem.setText("About");
        aboutItem.addSelectionListener(new SelectionListener() {
            public void widgetSelected(SelectionEvent e) {
            
               new ChildShell();
               
             }
        
         public void widgetDefaultSelected(SelectionEvent e) {

          }
        });

       
        shell.setMenuBar(m);
        shell.open();

  //positioning buttons
    
    label.setBounds(0, 0, 400, 60);
    buttonSelectDir.setBounds(0, 65, 200, 30);
    buttonSelectFile.setBounds(200, 65, 200, 30);
    heading.setBounds(0,100,200,20);
    buttonSingleClass.setBounds(0,120,130,20);
    buttonMultiClass.setBounds(0, 140, 130, 20);
    buttonClassIns.setBounds(0, 160, 130, 20);
    buttonClient.setBounds(0,180,130,20);
    buttonURI.setBounds(0,200,130,20);
    buttonPCE.setBounds(0,220,130,20);
    
    
    chooseExp.setBounds(0,260,120,20);
    buttonConexp.setBounds(0,280,110,20);
    buttonGalicia.setBounds(0,300,110,30);
    
    buttonIconSave.setBounds(80, 340, 120, 30);
    buttonStartExp.setBounds(210, 340, 130, 30);
   
    
    shell.setImage(new Image(display, "NUlogo.jpg"));
    shell.pack();
    shell.open();
    

    // Set up the event loop.
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        // If no more entries in event queue
        display.sleep();
      }
    }

    display.dispose();
  }




class ChildShell {

	
	
	ChildShell() {
	
	final Shell child = new Shell(SWT.TITLE | SWT.MIN | SWT.CLOSE);
    child.setSize(425,565);
    
    child.setImage(new Image(display, "NUlogo.jpg"));
    StyledText text = new StyledText(child, SWT.BORDER);
   
    GridLayout gridLayout = new GridLayout(4, false);
    gridLayout.verticalSpacing = 8;
    child.setLayout(gridLayout);
    child.setText("About FCA Parser");
    
   
    text.setText("                                         FCA Parser\n\n"+
    "Abstract:\n\n"+
    "Fcaparser parses java files to generate input for the Concept Explorers,\n" +
    "ConExp or Galicia, which later generates the concept lattice. It provides an\n"+
    "interface to the user to either select a package containing multiple or a\n"+
    "single java file followed by selection of technique to be applied, binary\n" +
    "file storage and lattice generation. \n\n"+
    
    "Techniques Supported:\n\n"+
      
    "The techniques supported include: \n\n"

    +"1. Method-Atrribute relationship.\n"+
    "2. Hierarchy Detection among Multiple Classes.\n"+
    "3. Methods Invoced and Atrributes accessed across Classes.\n"+
    "4. Refactoring Classes by examining Client Code.\n"+
    "5. URI/Gabin.\n"+
    "6. Principle Class Views.\n\n"+
    "Developers:\n\n"+
    
    "1. Shahzadi Samia.\n"+
    "2. Samia Azhar.\n"+
    "3. Aatira Anum Ahmad.\n"+
    "4. Amber Moein.\n\n"+
    
    
    "Special Thanks To:\n\n"+
    "Dr.Muhammad Usman Bhatti (FAST-NU, LHR, CS Department)\n\n");
    
    
    
    
    StyleRange style1 = new StyleRange();
    
    style1.start = 20;
    style1.length = 29;
    style1.fontStyle = SWT.BOLD;
    text.setStyleRange(style1);
    
    
  StyleRange style2 = new StyleRange();
    
    style2.start = 30;
    style2.length = 32;
    style2.fontStyle = SWT.BOLD;
    text.setStyleRange(style2);
   
 StyleRange style3 = new StyleRange();
    
    style3.start = 401;
    style3.length = 20;
    style3.fontStyle = SWT.BOLD;
    text.setStyleRange(style3);
   
    
   
 StyleRange style4 = new StyleRange();
    
    style4.start = 690;
    style4.length = 11;
    style4.fontStyle = SWT.BOLD;
    text.setStyleRange(style4);
    
    
 StyleRange style5 = new StyleRange();
    
    style5.start = 776;
    style5.length = 20;
    style5.fontStyle = SWT.BOLD;
    text.setStyleRange(style5);
    
    
    
    
    // Button.
    
    GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
	gridData.horizontalSpan = 40;
	gridData.horizontalAlignment = GridData.END;
	Button close = new Button(child, SWT.PUSH);
	close.setLayoutData(gridData);
    close.setText("Close");

    
    close.setBounds(400,500 , 500, 500);
    close.addSelectionListener(new SelectionAdapter(){;
    
    
    public void widgetSelected(SelectionEvent e) {
     
       
    	
    	child.close();
    }
  });

    
    
    child.open();
    
	} 
       
   }
	

}



